﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class SendAddress
{
    /// <summary>
    /// 添加收货地址
    /// </summary>
    /// <param name="receivename"></param>
    /// <param name="sex"></param>
    /// <param name="address"></param>
    /// <param name="postcode"></param>
    /// <param name="phone"></param>
    /// <param name="flagbuliding"></param>
    /// <param name="userID"></param>
    /// <returns></returns>
    public int Add(string receivename, string sex, string address, string postcode,
        string phone, string flagbuliding, int userID)
    {
        DataModelDataContext data = new DataModelDataContext();
        return data.Pr_AddSendAddress(receivename, sex, address, postcode, phone, flagbuliding, userID);
    }
    /// <summary>
    /// 修改
    /// </summary>
    /// <param name="receivename"></param>
    /// <param name="sex"></param>
    /// <param name="address"></param>
    /// <param name="postcode"></param>
    /// <param name="phone"></param>
    /// <param name="flagbuliding"></param>
    /// <param name="addressID"></param>
    /// <returns></returns>
    public void UpdateSendAddress(string receivename, string sex, string address, string postcode,
        string phone, string flagbuliding, int addressID)
    {
        DataModelDataContext data = new DataModelDataContext();
        data.Pr_UpdateSetSendAddress(receivename, sex, address, postcode, phone, flagbuliding, addressID);
    }

    //public void DeleteSendAddress(int addressID)
    //{
    //    DataModelDataContext data = new DataModelDataContext();
    //    data.Pr_deletesetSendAddress(addressID);
    //}

    /// <summary>
    /// 获得用户的地址
    /// </summary>
    /// <param name="userID"></param>
    /// <returns></returns>
    public DataTable GetAddressByUser(int userID)
    {
        DataModelDataContext data = new DataModelDataContext();
        var result = data.Pr_GetAddressByClient(userID);
        DataTable table = new DataTable();
        table = result.CopyToDataTable();
        return table;
    }
    /// <summary>
    /// 获得某个地址的详细信息
    /// </summary>
    /// <param name="addressID"></param>
    /// <returns></returns>
    //public DataTable GetAddressbyID(int addressID)
    //{

    //    //声明定义类型和方法的DataModelDataContext类的对象，它是调用模型和方法的基础。
    //    DataModelDataContext data = new DataModelDataContext();
    //    //调用方法Pr_GetAddressbyID获得某个地址的详细信息
    //    var result = data.Pr_GetAddressbyID(addressID);
    //    ///定义保存从数据库获取的结果的DataTable
    //    DataTable table = new DataTable();
    //    //把LINQ查询结果集转化为DataTable
    //    table = result.CopyToDataTable();
    //    return table;
    //}
}
